using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BusinessRules;
using DataAccess;
using Common;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;

public partial class Actividades : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ASPxButtonExportar_Click(object sender, EventArgs e)
    {
        ASPxGridViewExporterActividades.WriteXlsToResponse();
    }
    protected void ASPxGridViewActividades_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
    {
        if (!ASPxGridViewActividades.IsEditing || e.Column.FieldName != "PLN_ID") return;
        {
            ASPxComboBox combo = e.Editor as ASPxComboBox;
            SigPlanAccion objSigPlanAccion = new SigPlanAccion(ConfigurationManager.AppSettings["Conn"]);
            SigPlanAccionData objSigPlanAccionData = objSigPlanAccion.ConsultarPlanAccionAdministracionPer_Id(Usuario.PerfilActual.ToString());
            if (combo != null)
            {
                combo.DataSource = objSigPlanAccionData;
                combo.ValueField = SigPlanAccionData.PLN_ID_FIELD;
                combo.TextField = SigPlanAccionData.PLN_NOMBRE_FIELD;
                combo.DataBind();
            }
        }

    }
    protected void ASPxGridViewActividades_CommandButtonInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCommandButtonEventArgs e)
    {
        if (e.Button != null)
        {
            if (e.Button.ButtonType == ColumnCommandButtonType.New)
            {
                if (this.Permisos.Count > 0 && this.Permisos.Contains(Utilidad.Acciones.Adicionar))
                    e.Visible = true;
                else
                    e.Visible = false;
            }

            if (e.Button.ButtonType == ColumnCommandButtonType.Edit)
            {
                if (this.Permisos.Count > 0 && this.Permisos.Contains(Utilidad.Acciones.Actualizar))
                    e.Visible = true;
                else
                    e.Visible = false;
            }
            if (e.Button.ButtonType == ColumnCommandButtonType.Delete)
            {
                if (this.Permisos.Count > 0 && this.Permisos.Contains(Utilidad.Acciones.Eliminar))
                    e.Visible = true;
                else
                    e.Visible = false;
            }
        }
    }
}
